package com.itheima.mapper;

import com.itheima.pojo.OrderSetting;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface OrderSettingDao {
    /*
     * 根据日期修改可预约人数
     * */
    @Update("update t_ordersetting set number = #{number} where orderDate = date(#{orderDate})")
    void editNumberByOrderDate(OrderSetting orderSetting);

    /*
     * 根据年月查询对应的预约设置信息
     * */
    @Select("select orderDate date ,number,reservations from t_ordersetting where orderDate between #{firstDayOfMonth} and #{lastDayOfMonth}")
    List<OrderSetting> getOrderSettingByMonth(LocalDate firstDayOfMonth, LocalDate lastDayOfMonth);

    @Insert("insert into t_ordersetting(orderDate, number,reservations) values(#{orderDate},#{number},0)")
    void insert(String orderDate, String number);
}
